package com.mayikt.days07;

import java.lang.ref.WeakReference;

/**
 * @ClassName Test002
 * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
 * @Version V1.0
 **/
public class Test002 {
    public static void main(String[] args) {
        OrderEntity o1 = new OrderEntity("123456", "mayikt");
//        OrderEntity o2 = o1;
//        o1 = null;
//        System.out.println(o2.toString());
//        System.gc();
//        System.out.println("触发GC");
//        System.out.println(o2.toString());
        WeakReference<OrderEntity> orderWeak = new WeakReference<>(o1);
        o1 = null;
        System.out.println(orderWeak.get().toString());
        System.gc();
        System.out.println("触发GC");
        System.out.println(orderWeak.get());
    }
}
